<?php
namespace Api\Controller;
use Think\Controller;
class PictureController extends Controller {
 //  public function picturelist(){
  //      $pictureModel=M('picture');
  //      $data=$pictureModel->order('uid desc')->select();
  //      echo json_encode($data);
  //  }
    public function picturelist(){//当前用户所有晒图信息
    	$id=$_GET['uid'];
        $pictureModel=M('picture');
        $data=$pictureModel->where("uid='$id'")->select();
        echo json_encode($data);
    }
   // public function picturedetail(){
    //    $id["pid"]=I('get.pid');
   //     $data=M("picture")->where($id)->find();
   //    	echo json_encode($data);
   // }
    public function picturedetail(){//晒图详情
    	$id=$_GET['pid'];
        $pictureModel=M('picture');
        $data=$pictureModel->where("pid='$id'")->select();
        echo json_encode($data);
    }


    public function delpicture( )
    {

       // $id=I('id');
        $id=$_GET['pid'];
        $pictureModel = M('picture');//实例化news对象
        if($pictureModel->delete($id)) {
            //$this->success('删除成功');
            echo json_encode('1');
        }
        else {
          //  $this->error('删除失败');
            echo json_encode('0');
        }
    }

   /* public function addpicture()
    { 
		$pictureModel = M('picture');

        if ($pictureModel->create()) {
          
            if ($_FILES['file']['error'] == 0) {
                $logoinfo = $this->upload();
                $pname = $logoinfo['file']['savename'];
            } else {
                $pname = "default.jpg";
            }
            $user->telephone=trim(I('post.telephone'));
            $user->aliasname=trim(I('post.aliasname'));
            $password=trim(I('post.password'));
            $user->password=md5($password);
            $user->email=trim(I('post.email'));
            $user->photo=$pname;
            if (false !== $user->add()) {
                $this->success('注册成功！', 'login');
            } else {         $this->error('数据错误');           }
        } else {
            $this->error($user->getError());
        }
    }
    public function upload()
    {
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize = 3145728;// 设置附件上传大小
        $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath = './Public/Uploads/logo/'; // 设置附件上传根目录
        //$upload->savePath  =     ''; // 设置附件上传（子）目录
        $upload->autoSub = false;
        $info = $upload->upload();  // 上传文件
       
        if (!$info) {
            $this->error($upload->getError());
        } else {
            //$this->success('上传成功！');
            return $info;
        }
    }
    */
}